package com.econ.powercloud.ems.controller.highpressure;

import com.econ.powercloud.common.base.facade.pojo.MsgResult;
import com.econ.powercloud.ems.controller.ApiBaseController;
import com.econ.powercloud.ems.pojo.*;
import com.econ.powercloud.ems.service.biz.FlashNewDataService;
import io.swagger.annotations.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @Author : zjf
 * @Description : 这里的接口都是高压特有的
 * @Date : 2022/7/20 15:23
 * @Modified by : zjf
 */
@RestController
@Api(tags ="高压实时数据查询")
@RequestMapping(value = "/api/v2/high/flashData")
public class HighFlashNewDataController extends ApiBaseController {

    @Autowired
    private FlashNewDataService flashNewDataService;

    /**
     * 返回的结果按照储能装置划分
     * @param stationId
     * @return
     * 第一层是列,第二层是每一列的数据
     */
    @GetMapping(value = "getStationBAMSStaticalData")
    @ApiOperation(value="获取储能装置下的所有BAMS的统计数据", notes="获取储能站下的所有BAMS的统计数据")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "stationId", value = "储能站id", required = true, dataType = "String"),
            @ApiImplicitParam(name = "equipmentId", value = "储能装置id", required = true, dataType = "String")
    })
    public MsgResult<List<List<FlashVO>>> getStationBAMSStaticalData(@RequestParam(value = "stationId") String stationId,
                                                                           @RequestParam(value = "equipmentId")String equipmentId){
        return successHandler(flashNewDataService.getHighStationBAMSStaticalData(stationId,equipmentId));
    }

    @GetMapping(value = "getClusterDataByEquipment")
    @ApiOperation(value="获取储能装置下的单元体信息", notes="获取储能装置下的单元体信息")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "stationId", value = "储能站id", required = true, dataType = "String"),
            @ApiImplicitParam(name = "equipmentId", value = "储能装置id", required = true, dataType = "String")
    })
    public MsgResult<List<PhaseKindVO>> getBMSClusterData(@RequestParam(value = "stationId") String stationId,
                                                          @RequestParam(value = "equipmentId")String equipmentId){
        return successHandler(flashNewDataService.getHighBMSClusterData(stationId,equipmentId));
    }

    @GetMapping(value = "getClusterDataByPhase")
    @ApiOperation(value="获取某个相下的单元体信息", notes="获取某个相下的单元体信息")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "deviceCode", value = "相设备编号", required = true, dataType = "String"),
    })
    public MsgResult<List<ClusterKindVO>> getBMSClusterDataByPhase(@RequestParam(value = "deviceCode") String deviceCode){
        return successHandler(flashNewDataService.getClusterDataByPhase(deviceCode));
    }

    @GetMapping(value = "getDeviceMeterDataByDeviceCode")
    @ApiOperation(value="通过设备电表编号查询展示数据", notes="通过设备电表编号查询展示数据")
    @ApiImplicitParam(name = "deviceCode", value = "设备id", required = true, dataType = "String")
    public MsgResult<MeterVO> getDeviceMeterDataByDeviceCode(@RequestParam(value = "deviceCode") String deviceCode){
        return successHandler(flashNewDataService.getMeterDataByDeviceCode(deviceCode));
    }

    @GetMapping(value = "getProtectDeviceInfo")
    @ApiOperation(value="获取保护设备数据", notes="获取保护设备数据")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "stationId", value = "储能站id", required = true, dataType = "String"),
            @ApiImplicitParam(name = "equipmentId", value = "储能装置id", required = true, dataType = "String")
    })
    public MsgResult<List<ProtectDeviceVO>> getProtectDeviceInfo(@RequestParam(value = "stationId") String stationId,
                                                                     @RequestParam(value = "equipmentId")String equipmentId){
        return successHandler(flashNewDataService.getProtectDeviceInfo(stationId,equipmentId));
    }

    @GetMapping(value = "getClusterDataByBamsCode")
    @ApiOperation(value = "获取BMS设备下的单元体信息",notes = "获取BAMS设备下的单元体信息")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "deviceCode", value = "BAMS设备编号", required = true, dataType = "String")
    })
    public MsgResult<List<PhaseKindVO>> getClusterDataByBamsCode(@RequestParam(value = "deviceCode")String deviceCode){
        return successHandler(flashNewDataService.getClusterDataByBamsCode(deviceCode));
    }

    @GetMapping(value = "getSingleBamsStaticalData")
    @ApiOperation(value="获取单个BAMS的统计数据", notes="获取储能站下的所有BAMS的统计数据")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "deviceCode", value = "BAMS设备编号", required = true, dataType = "String")
    })
    public MsgResult<List<List<FlashVO>>> getSingleBamsStaticalData(@RequestParam(value = "deviceCode")String deviceCode){
        return successHandler(flashNewDataService.getSingleBAMSStaticalData(deviceCode));
    }
}
